Repository navigation
Add Open for a pool without the startup ping - #6
Merged
Mohammed Naser (mnaser) merged 2 commits intoNov 20, 2026
Merged
Conversation
ConnectContext pings and closes the pool when the database does not answer, so a caller that starts during a database outage has no pool at all. The OpenStack database exporter then reports its services as down until it is restarted, even after the database is back. Open does the parsing and pool setup without contacting the server, and ConnectContext becomes Open plus the ping, so existing callers behave as before. The pool connects on first use and reconnects after a lost connection. Tested with go test -race, go vet, gofmt and the integration suite. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Timon Schnell <timon.schnell@btc-it-services.com>
Mohammed Naser (mnaser)
self-requested a review
November 20, 2026 20:56
Open adds no dial timeout, so a pool held through a database outage does not fail fast. Say so in the Open doc comment and the README, and move the Open note into its own README paragraph. Signed-off-by: Mohammed Naser <mnaser@vexxhost.com>
Mohammed Naser (mnaser)
force-pushed
the
open-without-ping
branch
from
November 20, 2026 22:47
b77a736 to
1586227
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ConnectContextopens the pool, pings it, and closes it again when the pingfails. A caller that starts while its database is unreachable therefore ends up
with no pool at all, and has to build its own retry around
Connect.The OpenStack database exporter runs into exactly that: when it starts during a
database outage, it reports the affected services as down until it is
restarted, even after the database is back. Details in
vexxhost/openstack_database_exporter#150.
This adds
Open, which does the URL parsing, option validation and pool setupof
ConnectContextwithout contacting the server.ConnectContextbecomesOpenplus the ping, soConnectandConnectContextbehave as before. A poolfrom
Openconnects on first use and again after a lost connection, which iswhat
database/sqlalready does for a pool that was pinged once.Tests
TestOpenInvalidURLsandTestOpenInvalidOptionscover the same rejectionsas the
Connecttests.TestOpenUnreachableServergets a pool for a port nobody listens on, checksthe default pool limit, and checks that a ping on that pool still fails.
TestOpenOptionschecks that the options reach the pool.go test -race ./...,go vet ./...,gofmt -l .and the integration suite(
-tags integration) pass locally.The exporter change that uses it is ready and was tested against a production
like OpenStack control plane; it follows once this is released.